using UnityEngine;
using QFramework;

namespace dilao
{
	public partial class Ability : ViewController
	{
        private float Firetime = 1.5f;
        private void Update()
        {
            Firetime -= Time.deltaTime;
            if(Firetime<=0)
            {
                Firetime = 1.5f;
                var enemys = FindObjectsByType<Enemy>(FindObjectsInactive.Exclude,FindObjectsSortMode.None);
                foreach (var item in enemys)
                {
                    if (Vector3.Distance(Player.GetInstance().transform.position,item.transform.position)<5)
                    {
                       
                        item.Sprite.color = Color.red;
                        var enemy = item;
                        ActionKit.Delay(0.5f,() => {
                            enemy.Hp--;
                            enemy.Sprite.color = Color.white;
                        }).StartGlobal();
                    }
                }
            }
        }
    }
}
